from pydantic import BaseModel
from datetime import datetime

from forward.schema_base import EmptyStrToNone
from forward.utils.tools import ToolsUtil


class OperatorSchema(BaseModel):
    name: str | None = None
    phone: str | None = None
    status: int | None = None
    entry_time: datetime | None = None
    resignation_time: datetime | None = None
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class OperatorAddInSchema(OperatorSchema):
    pass


class OperatorOutSchema(OperatorSchema):
    id: int
    created_time: datetime | None = None


class OperatorEditInSchema(OperatorSchema):
    id: int


class OperatorStatusInSchema(BaseModel):
    id: int
    status: int


class OperatorListInSchema(BaseModel):
    name: str | None = None
    phone: str | None = None
    status: int | None | EmptyStrToNone = None
    entry_time: datetime | None | EmptyStrToNone = None
    resignation_time: datetime | None | EmptyStrToNone = None
    page_no: int = 1
    page_size: int = 15
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class OperatorDetailInSchema(BaseModel):
    id: int


class OperatorConfigInSchema(BaseModel):
    dept_id: str
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }
